/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-29 12:44:05
 * @Description  : 计划任务相关接口
 */

import type {
  ScheduleTaskCreateReq,
  ScheduleTaskPageRes,
  ScheduleTaskUpdateReq,
  ScheduleTaskReq
} from '@/types/scheduleTask'
import request from '@/utils/request'

// 分页查询计划任务接口
export const getScheduleTaskByPage = (params?: ScheduleTaskReq) => {
  return request.get<ScheduleTaskPageRes>('/scheduleTask/list', { params })
}

// 添加计划任务接口
export const createScheduleTask = (data: ScheduleTaskCreateReq) => {
  return request.post('/scheduleTask/create', data)
}

// 更新计划任务接口
export const updateScheduleTask = (data: ScheduleTaskUpdateReq) => {
  return request.put('/scheduleTask/update', data)
}

// 计划任务排序接口
export const sortScheduleTask = (scheduleTaskIds: string[]) => {
  return request.put('/scheduleTask/sort', { scheduleTaskIds })
}

// 计划任务删除接口
export const delScheduleTask = (
  scheduleTaskIds: string[],
  picCode?: string
) => {
  return request.delete('/scheduleTask/delete', {
    data: { scheduleTaskIds, picCode }
  })
}

// 计划任务运行接口
export const runScheduleTask = (scheduleTaskId: string) => {
  return request.post('/scheduleTask/run', { scheduleTaskId })
}
